#include "Quad.h"


Quad::Quad(Point& pos,float w,float h)
{
	float w2 = w * 0.5, h2 = h * 0.5;
	Point tl = pos+Point(-w2,-h2); 
	Point tr = pos+Point(w2,-h2); 
	Point br = pos+Point(w2,h2);
	Point bl = pos+Point(-w2,h2);
	t[0] = Traingle(tl,tr,br);
	t[1] = Traingle(tl,br,bl);
}

Quad::Quad( Point& tl,Point& tr,Point& br,Point& bl )
{
	t[0] = Traingle(tl,tr,br);
	t[1] = Traingle(tl,br,bl);
}

Quad::~Quad(void)
{
}

void Quad::draw( IPixelDrawer* dr )
{
	t[0].draw(dr);
	t[1].draw(dr);
}

void Quad::mulMat( Mat4& mat )
{
	t[0].mulMat(mat);
	t[1].mulMat(mat);
}

void Quad::setTexture( Texture* texture,Vec3& uvPos,float uvW,float uvH )
{
	Vec3 tr = uvPos+Vec3(uvW,0);
	Vec3 br = uvPos+Vec3(uvW,uvH);
	Vec3 bl = uvPos+Vec3(0,uvH);
	t[0].setTexture(texture,uvPos,tr,br);
	t[1].setTexture(texture,uvPos,br,bl);
}

void Quad::setShowBorder( bool b )
{
	t[0].setShowBorder(b);
	t[1].setShowBorder(b);
	IPrimitive::setShowBorder(b);
}
